package com.jwds.digital.bios.business.core.infrastructure.dto.belt.assembler;

import com.jwds.digital.bios.business.core.infrastructure.dto.belt.BeltDayTargetHisReqDTO;
import com.jwds.digital.bios.business.core.infrastructure.vo.belt.BeltDayTargetHisRespVO;
import com.jwds.digital.bios.business.core.infrastructure.entity.belt.BeltDayTargetHis;
import java.util.Objects;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * BeltDayTargetHis DTO与Entity之间的相互转换
 *
 * @author 林柏云
 * @date 2024-12-12
 */
public class BeltDayTargetHisAssembler {

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @return 实体对象
  */
  public static BeltDayTargetHis dto2entity(BeltDayTargetHisReqDTO dto)  {
    if (dto == null) {
      return null;
    }
    BeltDayTargetHis entity = new BeltDayTargetHis();
    entity.setWorkEfficiency(dto.getWorkEfficiency());
    entity.setTotalPowerConsumption(dto.getTotalPowerConsumption());
    entity.setUnLoadRunningTime(dto.getUnLoadRunningTime());
    entity.setUnLoadPowerConsumptionRate(dto.getUnLoadPowerConsumptionRate());
    entity.setTonPowerConsumption(dto.getTonPowerConsumption());
    return entity;
  }

  /**
  * 将传输对象转换为实体对象
  *
  * @param dto 传输对象
  * @param entity 原实体对象
  * @return 实体对象
  */
  public static BeltDayTargetHis dto2entity(BeltDayTargetHisReqDTO dto, BeltDayTargetHis entity){
    if (dto == null) {
      return null;
    }
    if(Objects.nonNull(dto.getWorkEfficiency())) {
      entity.setWorkEfficiency(dto.getWorkEfficiency());
    }
    if(Objects.nonNull(dto.getTotalPowerConsumption())) {
      entity.setTotalPowerConsumption(dto.getTotalPowerConsumption());
    }
    if(Objects.nonNull(dto.getUnLoadRunningTime())) {
      entity.setUnLoadRunningTime(dto.getUnLoadRunningTime());
    }
    if(Objects.nonNull(dto.getUnLoadPowerConsumptionRate())) {
      entity.setUnLoadPowerConsumptionRate(dto.getUnLoadPowerConsumptionRate());
    }
    if(Objects.nonNull(dto.getTonPowerConsumption())) {
      entity.setTonPowerConsumption(dto.getTonPowerConsumption());
    }
    return entity;
  }

  /**
  * 将实体对象转换为传输对象
  *
  * @param entity 实体对象
  * @return 传输对象
  */
  public static BeltDayTargetHisRespVO entity2dto(BeltDayTargetHis entity) {
    if (entity == null) {
      return null;
    }
    BeltDayTargetHisRespVO dto = new BeltDayTargetHisRespVO();
    dto.setId(entity.getId());
    dto.setWorkEfficiency(entity.getWorkEfficiency());
    dto.setTotalPowerConsumption(entity.getTotalPowerConsumption());
    dto.setUnLoadRunningTime(entity.getUnLoadRunningTime());
    dto.setUnLoadPowerConsumptionRate(entity.getUnLoadPowerConsumptionRate());
    dto.setTonPowerConsumption(entity.getTonPowerConsumption());
    dto.setCreateUser(entity.getCreateUser());
    dto.setCreateTime(entity.getCreateTime());
    dto.setModifyUser(entity.getModifyUser());
    dto.setModifyTime(entity.getModifyTime());
    return dto;
  }

}
